package com.edu.spider.enity;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TrainInfo implements Serializable {
    private String id;

    private String trainName;

    private String startStationName;

    private String isStartStation;

    private String endStationName;

    private String isEndStation;

    private String stratTime;

    private String endTime;

    private String takeTime;

    private String useTime;

    private Integer takeDays;

    private String isDirect;

    private String isBookable;

    private Integer preSaleDay;

    private String hardSeatPrice;

    private Integer hardSeatLast;

    private String softSleeperPrice;

    private Integer softSleeperLast;

    private String hardSleeperPrice;

    private Integer hardSleeperLast;

    private String normalSeatPrice;

    private Integer normalSeatLast;

    private String firstClassSeatPrice;

    private Integer firstClassSeatLast;

    private String secondClassSeatPrice;

    private Integer secondClassSeatLast;

    private String noSeatPrice;

    private Integer noSeatLast;

    private String principalSeatPrice;

    private Integer principalSeatLast;

    private Date createTime;

    private static final long serialVersionUID = 1L;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getTrainName() {
        return trainName;
    }

    public void setTrainName(String trainName) {
        this.trainName = trainName == null ? null : trainName.trim();
    }

    public String getStartStationName() {
        return startStationName;
    }

    public void setStartStationName(String startStationName) {
        this.startStationName = startStationName == null ? null : startStationName.trim();
    }

    public String getIsStartStation() {
        return isStartStation;
    }

    public void setIsStartStation(String isStartStation) {
        this.isStartStation = isStartStation == null ? null : isStartStation.trim();
    }

    public String getEndStationName() {
        return endStationName;
    }

    public void setEndStationName(String endStationName) {
        this.endStationName = endStationName == null ? null : endStationName.trim();
    }

    public String getIsEndStation() {
        return isEndStation;
    }

    public void setIsEndStation(String isEndStation) {
        this.isEndStation = isEndStation == null ? null : isEndStation.trim();
    }

    public String getStratTime() {
        return stratTime;
    }

    public void setStratTime(String stratTime) {
        this.stratTime = stratTime == null ? null : stratTime.trim();
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime == null ? null : endTime.trim();
    }

    public String getTakeTime() {
        return takeTime;
    }

    public void setTakeTime(String takeTime) {
        this.takeTime = takeTime == null ? null : takeTime.trim();
    }

    public String getUseTime() {
        return useTime;
    }

    public void setUseTime(String useTime) {
        this.useTime = useTime == null ? null : useTime.trim();
    }

    public Integer getTakeDays() {
        return takeDays;
    }

    public void setTakeDays(Integer takeDays) {
        this.takeDays = takeDays;
    }

    public String getIsDirect() {
        return isDirect;
    }

    public void setIsDirect(String isDirect) {
        this.isDirect = isDirect == null ? null : isDirect.trim();
    }

    public String getIsBookable() {
        return isBookable;
    }

    public void setIsBookable(String isBookable) {
        this.isBookable = isBookable == null ? null : isBookable.trim();
    }

    public Integer getPreSaleDay() {
        return preSaleDay;
    }

    public void setPreSaleDay(Integer preSaleDay) {
        this.preSaleDay = preSaleDay;
    }

    public String getHardSeatPrice() {
        return hardSeatPrice;
    }

    public void setHardSeatPrice(String hardSeatPrice) {
        this.hardSeatPrice = hardSeatPrice == null ? null : hardSeatPrice.trim();
    }

    public Integer getHardSeatLast() {
        return hardSeatLast;
    }

    public void setHardSeatLast(Integer hardSeatLast) {
        this.hardSeatLast = hardSeatLast;
    }

    public String getSoftSleeperPrice() {
        return softSleeperPrice;
    }

    public void setSoftSleeperPrice(String softSleeperPrice) {
        this.softSleeperPrice = softSleeperPrice == null ? null : softSleeperPrice.trim();
    }

    public Integer getSoftSleeperLast() {
        return softSleeperLast;
    }

    public void setSoftSleeperLast(Integer softSleeperLast) {
        this.softSleeperLast = softSleeperLast;
    }

    public String getHardSleeperPrice() {
        return hardSleeperPrice;
    }

    public void setHardSleeperPrice(String hardSleeperPrice) {
        this.hardSleeperPrice = hardSleeperPrice == null ? null : hardSleeperPrice.trim();
    }

    public Integer getHardSleeperLast() {
        return hardSleeperLast;
    }

    public void setHardSleeperLast(Integer hardSleeperLast) {
        this.hardSleeperLast = hardSleeperLast;
    }

    public String getNormalSeatPrice() {
        return normalSeatPrice;
    }

    public void setNormalSeatPrice(String normalSeatPrice) {
        this.normalSeatPrice = normalSeatPrice == null ? null : normalSeatPrice.trim();
    }

    public Integer getNormalSeatLast() {
        return normalSeatLast;
    }

    public void setNormalSeatLast(Integer normalSeatLast) {
        this.normalSeatLast = normalSeatLast;
    }

    public String getFirstClassSeatPrice() {
        return firstClassSeatPrice;
    }

    public void setFirstClassSeatPrice(String firstClassSeatPrice) {
        this.firstClassSeatPrice = firstClassSeatPrice == null ? null : firstClassSeatPrice.trim();
    }

    public Integer getFirstClassSeatLast() {
        return firstClassSeatLast;
    }

    public void setFirstClassSeatLast(Integer firstClassSeatLast) {
        this.firstClassSeatLast = firstClassSeatLast;
    }

    public String getSecondClassSeatPrice() {
        return secondClassSeatPrice;
    }

    public void setSecondClassSeatPrice(String secondClassSeatPrice) {
        this.secondClassSeatPrice = secondClassSeatPrice == null ? null : secondClassSeatPrice.trim();
    }

    public Integer getSecondClassSeatLast() {
        return secondClassSeatLast;
    }

    public void setSecondClassSeatLast(Integer secondClassSeatLast) {
        this.secondClassSeatLast = secondClassSeatLast;
    }

    public String getNoSeatPrice() {
        return noSeatPrice;
    }

    public void setNoSeatPrice(String noSeatPrice) {
        this.noSeatPrice = noSeatPrice == null ? null : noSeatPrice.trim();
    }

    public Integer getNoSeatLast() {
        return noSeatLast;
    }

    public void setNoSeatLast(Integer noSeatLast) {
        this.noSeatLast = noSeatLast;
    }

    public String getPrincipalSeatPrice() {
        return principalSeatPrice;
    }

    public void setPrincipalSeatPrice(String principalSeatPrice) {
        this.principalSeatPrice = principalSeatPrice == null ? null : principalSeatPrice.trim();
    }

    public Integer getPrincipalSeatLast() {
        return principalSeatLast;
    }

    public void setPrincipalSeatLast(Integer principalSeatLast) {
        this.principalSeatLast = principalSeatLast;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", trainName=").append(trainName);
        sb.append(", startStationName=").append(startStationName);
        sb.append(", isStartStation=").append(isStartStation);
        sb.append(", endStationName=").append(endStationName);
        sb.append(", isEndStation=").append(isEndStation);
        sb.append(", stratTime=").append(stratTime);
        sb.append(", endTime=").append(endTime);
        sb.append(", takeTime=").append(takeTime);
        sb.append(", useTime=").append(useTime);
        sb.append(", takeDays=").append(takeDays);
        sb.append(", isDirect=").append(isDirect);
        sb.append(", isBookable=").append(isBookable);
        sb.append(", preSaleDay=").append(preSaleDay);
        sb.append(", hardSeatPrice=").append(hardSeatPrice);
        sb.append(", hardSeatLast=").append(hardSeatLast);
        sb.append(", softSleeperPrice=").append(softSleeperPrice);
        sb.append(", softSleeperLast=").append(softSleeperLast);
        sb.append(", hardSleeperPrice=").append(hardSleeperPrice);
        sb.append(", hardSleeperLast=").append(hardSleeperLast);
        sb.append(", normalSeatPrice=").append(normalSeatPrice);
        sb.append(", normalSeatLast=").append(normalSeatLast);
        sb.append(", firstClassSeatPrice=").append(firstClassSeatPrice);
        sb.append(", firstClassSeatLast=").append(firstClassSeatLast);
        sb.append(", secondClassSeatPrice=").append(secondClassSeatPrice);
        sb.append(", secondClassSeatLast=").append(secondClassSeatLast);
        sb.append(", noSeatPrice=").append(noSeatPrice);
        sb.append(", noSeatLast=").append(noSeatLast);
        sb.append(", principalSeatPrice=").append(principalSeatPrice);
        sb.append(", principalSeatLast=").append(principalSeatLast);
        sb.append(", createTime=").append(createTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
    
    /**
   	 * Author:ljl
   	 * Date:2018年9月19日下午2:53:56
   	 * Title: fromTrainItems 
   	 * Description:
   	 * @param trainItem
   	 * @return
   	 */
   	public static TrainInfo fromTrainItems(TrainItem trainItem) {
   		TrainInfo trainInfo = new TrainInfo();
   		trainInfo.setId(UUID.randomUUID().toString().replace("-", ""));
   		trainInfo.setTrainName(trainItem.getTrainName());
   		trainInfo.setStartStationName(trainItem.getStartStationName());
   		trainInfo.setIsStartStation(String.valueOf(trainItem.getIsStartStation()));
   		trainInfo.setEndStationName(trainItem.getEndStationName());
   		trainInfo.setIsEndStation(String.valueOf(trainItem.getIsEndStation()));
   		trainInfo.setStratTime(trainItem.getStratTime());
   		trainInfo.setEndTime(trainItem.getEndTime());
   		trainInfo.setTakeTime(trainItem.getTakeTime());
   		trainInfo.setUseTime(trainItem.getUseTime());
   		trainInfo.setTakeDays(trainItem.getTakeDays());
   		trainInfo.setIsDirect(String.valueOf(trainItem.getIsDirect()));
   		trainInfo.setIsBookable(String.valueOf(trainItem.getIsBookable()));
   		trainInfo.setPreSaleDay(trainItem.getPreSaleDay());
   		for (SeatBooking seatBooking : trainItem.getSeatBookingItem()) {
   			if(seatBooking.getSeatName().equals("硬　座")){
   				trainInfo.setHardSeatPrice(seatBooking.getPrice());
   				trainInfo.setHardSeatLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("硬　卧")){
   				trainInfo.setHardSleeperPrice(seatBooking.getPrice());
   				trainInfo.setHardSleeperLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("软　卧")){
   				trainInfo.setSoftSleeperPrice(seatBooking.getPrice());
   				trainInfo.setSoftSleeperLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("商务座")){
   				trainInfo.setNormalSeatPrice(seatBooking.getPrice());
   				trainInfo.setNormalSeatLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("一等座")){
   				trainInfo.setFirstClassSeatPrice(seatBooking.getPrice());
   				trainInfo.setFirstClassSeatLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("二等座")){
   				trainInfo.setSecondClassSeatPrice(seatBooking.getPrice());
   				trainInfo.setSecondClassSeatLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("无　座")){
   				trainInfo.setNoSeatPrice(seatBooking.getPrice());
   				trainInfo.setNoSeatLast(seatBooking.getInventory());
   			}else if(seatBooking.getSeatName().equals("特等座")){
   				trainInfo.setPrincipalSeatPrice(seatBooking.getPrice());
   				trainInfo.setPrincipalSeatLast(seatBooking.getInventory());
   			}else{
   				log.info("=============================车次号:"+trainItem.getTrainName()+"=============================");
   				log.info("=============================未知的座位类型:"+seatBooking.getSeatName()+"=============================");
   			}
   		}		
   		return trainInfo;
   	}
      
}